interface ILength {
  length: number
}

function id<Type  extends ILength> (value: Type) {
  return value.length
}

console.log(id('123'))
console.log(id([1, 2, 3]))
// id(123)